<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>校验测试</title>
    <script>
    function validate_required(field, alerttxt)
    {
        with(field)
        {
            if (value == null || value == "")
            {
                alert(alerttxt);
                return false;
            }
        }
    }

    function validate_email(field, alert_txt)
    {
        with (field)
        {
            apos = value.indexOf("@");
            dotpos = value.lastIndexOf(".");
            if (apos < 1 || dotpos - apos < 2)
            {
                alert(alert_txt);
                return false;
            }
            else
            {
                return true;
            }
        }
    }

    function validate_form(this_form)
    {
        with(this_form)
        {
            if (validate_required(email, "Email must be filled out!") == false)
            {
                email.focus();
                return false;
            }
            if (validate_email(email, "Not a valid e-mail address!") == false)
            {
                email.focus();
                return false;
            }
        }
    }
</script>
</head>
<body>
<form action="submitpage.htm" onsubmit="return validate_form(this)" method="post">
    <!--输入类型为text，列名为email， size为30-->
    Email: <input type="text" name="email" size="30">
    <input type="submit" value="Submit">
</form>
</body>
</html>